<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="lib/jquery-3.3.1.js"></script>
    <style>
        .test{
            width:100px;
            height:100px;
            background: red;
            margin-top: 100px;
            margin-left: 100px;
        }
        #one{
            width:200px;
            height:200px;
            background: gray;
            position: relative;
        }
        #child{
            width:50px;
            height:50px;
            background: green;
            position: absolute;
            left:50px;
            top:50px;
        }
    </style>
</head>
<body>
    <div class="test"></div>
    <div id="one">
        <div id="child">

        </div>
    </div>
    <script>
        var offsetTop= $(".test").offset().top;
        var offsetLeft = $(".test").offset().left;
        console.log(offsetTop);
        console.log(offsetLeft);
        var left = $("#child").position().left;
        console.log(left);
        $(window).scroll(function(){
            var scroll = $(window).scrollTop();
            console.log(scroll);
        })
    </script>
</body>
</html>